# ES-IDE build file
# We use Py2Exe to build the exes and so on
from distutils.core import setup
import py2exe
from third_party.path import path
import os

# paths
release = path("../release/latest")
root = path(os.getcwd())

def clean(p):
    for d in p.dirs():
        clean(d)
        for f in d.files():
            print "Removing",f
            f.remove()
        print "Removing",d
        d.rmdir()
 
# pre-clean the release dir
clean(release)
# clean the build dir
clean(root / "build")

raw_input("press any key to continue build")

# dev note: console=[] refers to console exes, GUI's need to be called with windows=[]
setup(
zipfile=None,
console=['PySrcds.py',"es-ide.py"],
options={"py2exe":{"dist_dir":"../release/latest"}},
name='es-ide',
version='1.0',
description='EventScripts IDE',
author='Thomas Morton',
author_email='morton.thomas@googlemail.com',
url='es-ide.googlecode.com',)
# zipfile: the location of the packaged zip libraries
# console: console exe's to build

# directory structure of support files
dirstruct = []
dirstruct.append("data")
dirstruct.append("userdata")
dirstruct.append("userdata/default")

# listo f support files
filestruct = []
filestruct.append("data/data.zip")
filestruct.append("userdata/default/default.ini")

# copy the directory and support files over...
for dir in dirstruct:
    path(release / dir).mkdir(1)
for file in filestruct:
    path(root / file).copy(release / file)
    
# and finally clean the build dir again
clean(root / "build")